home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / 8bit / cislib_b / numuti.txt < prev    next >
Text File  |  1995-04-22  |  2KB  |  1 lines

  1. NUMBER ASSIGNMENT UTILITIESby Erik WarrenDuring the course of editing a Pascal program or routine, you may find that youare using the statements similar to the following ones very often:    My_Int := My_Int + 1;    My_Int := My_Int - Your_Int;    My_Int := 0;All of those assignment statements require a large number of keystrokes andSHIFTing.  In addition to being a generally lazy person, I am also a lazytypist (and a poor one at that), so I wrote three quick routines thatincrement, decrement, and initialize integer variables.  These are similar toroutines used in Professor Niklaus Wirth's latest (and greatest) programminglanguage, Modula-2.Inc first requires a variable passed to it, followed by a number or variable tobe used as the increment value.  The second parameter is added to the first.The following statements are possible uses of Inc:    Inc(My_Int,1); (* My_Int := My_Int + 1; *)    Inc(My_Int,Your_Int); (* My_Int := My_Int + Your_Int; *)Dec requires the same parameters as Inc, but it subtracts the second parameterfrom the first instead of adding the two together.  The following statementsare possible uses of Dec:    Dec(My_Int,255); (* My_Int := My_Int - 255; *)    Dec (My_Int,Your_Int); (* My_Int := My_Int - Your_Int; *)Init requires only one parameter, and it will be initialized to the value zero.For example:    Init(My_Int); (* My_Int := 0; *)As you may have guessed by looking at the examples, these routines work onlywith Integers, but they may be changed easily to work with variables of otherdata types:PROCEDURE Inc(VAR Dest : Integer; Src  :  Integer);BEGIN    Dest  := Dest + SourceEND; (*  Increment  *)PROCEDURE Dec(VAR Dest : Integer; Src  :  Integer);BEGIN    Dest  := Dest  -  SourceEND; (*  Decrement  *)PROCEDURE Init(VAR Num  :  Integer);BEGIN    Num  := 0END;(*  Initialize  *)